/**
 *
 */
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @signatureAlgorithm = 'v2';
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('wuyingsolutionframework', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model SendOpsMessageToTerminalRequest {
  messageBody?: string(name='MessageBody', example='text'),
  officeRegionId?: string(name='OfficeRegionId', example='cn-hangzhou'),
  opsAction?: string(name='OpsAction', example='reboot'),
  serialNo?: string(name='SerialNo', example='AAAAAAAAAAAA'),
  waitForAck?: boolean(name='WaitForAck', example='true'),
  waitForMsg?: boolean(name='WaitForMsg', example='false'),
}

model SendOpsMessageToTerminalResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message', example='message'),
  requestId?: string(name='RequestId', example='2F015A9B-C457-5E5A-A58D-215CCEBC4A80'),
  success?: boolean(name='Success', example='true'),
}

model SendOpsMessageToTerminalResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: SendOpsMessageToTerminalResponseBody(name='body'),
}

/**
 * @summary 发送运维消息
 *
 * @param request SendOpsMessageToTerminalRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return SendOpsMessageToTerminalResponse
 */
async function sendOpsMessageToTerminalWithOptions(request: SendOpsMessageToTerminalRequest, runtime: $RuntimeOptions): SendOpsMessageToTerminalResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.messageBody)) {
    query['MessageBody'] = request.messageBody;
  }
  if (!$isNull(request.officeRegionId)) {
    query['OfficeRegionId'] = request.officeRegionId;
  }
  if (!$isNull(request.opsAction)) {
    query['OpsAction'] = request.opsAction;
  }
  if (!$isNull(request.serialNo)) {
    query['SerialNo'] = request.serialNo;
  }
  if (!$isNull(request.waitForAck)) {
    query['WaitForAck'] = request.waitForAck;
  }
  if (!$isNull(request.waitForMsg)) {
    query['WaitForMsg'] = request.waitForMsg;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'SendOpsMessageToTerminal',
    version = '2023-08-10',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 发送运维消息
 *
 * @param request SendOpsMessageToTerminalRequest
 * @return SendOpsMessageToTerminalResponse
 */
async function sendOpsMessageToTerminal(request: SendOpsMessageToTerminalRequest): SendOpsMessageToTerminalResponse {
  var runtime = new $RuntimeOptions{};
  return sendOpsMessageToTerminalWithOptions(request, runtime);
}

